\defmodule {CauchyGen}

This class implements random variate generators for the {\em Cauchy\/} 
distribution. The density is
\begin{htmlonly}%
\eq
  f(x) = \beta/(\pi[(x - \alpha)^2 + \beta^2])
\mbox{ for }-\infty < x < \infty,
\endeq
\end{htmlonly}%
\begin{latexonly}%
(see, e.g., \cite {tJOH95a} p.\ 299):
\eq 
    f (x) = \frac{\beta}{\pi[(x-\alpha)^2 + \beta^2]},
             \qquad  \mbox{for } -\infty < x < \infty, \eqlabel{eq:fcauchy}
\endeq
\end{latexonly}
where $\beta > 0$.

The (non-static) \texttt{nextDouble} method simply calls 
\texttt{inverseF} on the distribution.

\bigskip\hrule

\begin{code}
\begin{hide}
/*
 * Class:        CauchyGen
 * Description:  random variate generators for the Cauchy distribution
 * Environment:  Java
 * Software:     SSJ 
 * Copyright (C) 2001  Pierre L'Ecuyer and Universite de Montreal
 * Organization: DIRO, Universite de Montreal
 * @author       
 * @since

 * SSJ is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License (GPL) as published by the
 * Free Software Foundation, either version 3 of the License, or
 * any later version.

 * SSJ is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * A copy of the GNU General Public License is available at
   <a href="http://www.gnu.org/licenses">GPL licence site</a>.
 */
\end{hide}
package umontreal.iro.lecuyer.randvar;\begin{hide}
import umontreal.iro.lecuyer.rng.*;
import umontreal.iro.lecuyer.probdist.*;
\end{hide}

public class CauchyGen extends RandomVariateGen \begin{hide} {
   protected double alpha;
   protected double beta;
\end{hide}
\end{code}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection* {Constructors}
\begin{code}

   public CauchyGen (RandomStream s, double alpha, double beta) \begin{hide} {
      super (s, new CauchyDist(alpha, beta));
      setParams(alpha, beta);
   }\end{hide}
\end{code} 
\begin{tabb} Creates a Cauchy random variate generator with parameters
  $\alpha =$ \texttt{alpha} and $\beta$ = \texttt{beta},
    using stream \texttt{s}. 
\end{tabb}
\begin{code}

   public CauchyGen (RandomStream s) \begin{hide} {
      this (s, 0.0, 1.0);
   }\end{hide}
\end{code} 
\begin{tabb} Creates a Cauchy random variate generator with parameters
  $\alpha =0 $ and $\beta = 1$, using stream \texttt{s}. 
\end{tabb}
\begin{code}

   public CauchyGen (RandomStream s, CauchyDist dist) \begin{hide} {
      super (s, dist);
      if (dist != null)
         setParams(dist.getAlpha(), dist.getBeta());
   }\end{hide}
\end{code}
\begin{tabb} Create a new generator for the distribution \texttt{dist},
     using stream \texttt{s}.
\end{tabb}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
\subsubsection* {Methods}
\begin{code}

   public static double nextDouble (RandomStream s,
                                    double alpha, double beta)\begin{hide} {
      return CauchyDist.inverseF (alpha, beta, s.nextDouble());
   }\end{hide}
\end{code}
\begin{tabb}
 Generates a new variate from the {\em Cauchy\/} distribution with parameters
 $\alpha = $~\texttt{alpha} and $\beta = $~\texttt{beta}, using stream \texttt{s}.
\end{tabb}
\begin{code}

   public double getAlpha()\begin{hide} {
      return alpha;
   }\end{hide}
\end{code}
\begin{tabb} Returns the parameter $\alpha$ of this object.
\end{tabb}
\begin{code}

   public double getBeta()\begin{hide} {
      return beta;
   }\end{hide}
\end{code}
\begin{tabb} Returns the parameter $\beta$ of this object.
\end{tabb}
\begin{code}\begin{hide}

   protected void setParams (double alpha, double beta) {
      if (beta <= 0.0)
         throw new IllegalArgumentException ("beta <= 0");
      this.alpha = alpha;
      this.beta = beta;
   }
}\end{hide}
\end{code}
